import React, { Component } from 'react'
import PubSub from 'pubsub-js';
export default class Header extends Component {
    render() {
        return (
            <section className="jumbotron">
                <h3 className="jumbotron-heading">搜索 GitHub 用户</h3>
                <div>
                    <input type="text" ref={el => this.input = el} placeholder="enter the name you search" />&nbsp;<button onClick={this.search}>搜索</button>
                </div>
            </section>
        )
    }

    search = () => {
        //获取用户输入的关键字
        let keyword = this.input.value;
        //发布消息   字符串
        PubSub.publish('github', {
            keyword: keyword
        });
    }
}
